//90pts 什么玄学bug推给编译器了
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int tim;
int rightn = 0;
int kpm;
char s1[10001][1001];   //s1为模板
char s2[10001][1001];   //s2是那家伙打的
int cnt[1001];          //每行字符计数
//先行内后行数
char tmp[10001];
int ptr;
int arr;
//1为模板，2为那家伙打的

int main(){
    //读入模板
    ptr = 1;
    while(true){
    cin.getline(tmp, 10001);
        if(strlen(tmp) == 3 && tmp[0] == 'E' && tmp[1] == 'O' && tmp[2] == 'F'){
            break;
        }
        else {
            cnt[ptr] = strlen(tmp);
            arr = 1;
            for(int i = 0; i < strlen(tmp); i++){
                if(tmp[i] == '<' && arr != 1){
                    arr--;
                    cnt[ptr] -= 2;
                }
                else if(tmp[i] == '<' && arr == 1){
                    cnt[ptr] -= 1;
                    continue;
                }
                else{
                    s1[arr][ptr] = tmp[i];
                    arr++;
            }
        }
            ptr++;
        }
    }
    int n = ptr - 1; // n为输入行数

    //读入那家伙打的
    ptr = 1;
    while(true){
    cin.getline(tmp, 10001);
        if(strlen(tmp) == 3 && tmp[0] == 'E' && tmp[1] == 'O' && tmp[2] == 'F'){
            break;
        }
        else{
            arr = 1;
            for(int i = 0; i < strlen(tmp); i++){
                if(tmp[i] == '<' && arr != 1){
                    arr--;
                }
                else if(tmp[i] == '<' && arr == 1){
                    continue;
                }
            else{
                s2[arr][ptr] = tmp[i];
                arr++;
            } 
        }
            ptr++;
        }
        
    }

    //比较
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= cnt[k]; i++){
            if (s1[i][k] == s2[i][k])   rightn++;
        }
        //cout << rightn << " ";
    }
    cin >> tim;
    cout << round(rightn * 60 / tim);
    return 0;
}